<html>
<header>
<title>BASIC! Program Editor</title>
<script>
  var pktCounter = 0;
  var URL = "http://{HOST}:8080";

  // cmd: play, manual etc.
  // params: dx=123&dy=456
  function httpGet(cmd, params)
  {
    var xmlHttp = new XMLHttpRequest();
    theUrl = URL + "/" + cmd + "?pkt=" + pktCounter;
    pktCounter++;
    if (params != "") theUrl += "&" + params;
    xmlHttp.open( "GET", theUrl, true ); 
	//xmlHttp.timeout = 1000;
    xmlHttp.send(null);    
  }

  function load(){
  }

  function run(){
    var value = document.getElementById("editor").value;
    httpGet("run", "code="+encodeURIComponent(value));
  }

  function stop(){
    httpGet("stop", "");
  }


</script>
</header>
<body onload="load()" style="background-color:lightgrey;">

<div>
  <button onclick="run()">Run</button><button onclick="stop()">Stop</button>
</div>

<textarea id="editor" rows="35" cols="120">{EDITOR}</textarea><br>
Web editor => device:  Press 'Run' to transfer above code to your Android device.<br>
device => Web editor:  Reload this page (CTRL+R) to transfer the Android device code to this Web editor.<br>

</body>
</html>
